#!/usr/bin/env coffee
import {倒计时} from './count_down.coffee'
import {工具条} from './recbar.coffee'
import fullscreen from '../fullscreen.coffee'
import {windowManager} from '@rmw/node-window-manager'

{area,win_area} = fullscreen
win = undefined

export wintop = (id)=>
  id_win = undefined
  for i from windowManager.getWindows()
    if id == i.id
      id_win = i
      break
  if id_win
    win.setAlwaysOnTop(false)
    id_win.bringToTop()
    top()
    #setTimeout(
    #  =>
    #    id_win.bringToTop()
    #    top()
    #    return
    #  100
    #)
  return

top = =>
  win.setAlwaysOnTop(true,'screen-saver')
  return

open = (func)=>
  win = func()
  top()
  win.on 'close',=>
    win = undefined
  return


export 选择窗口 = =>
  open win_area

export 选择区域 = =>
  open area

#close = =>
#  if win
#    win.close()
#    win.destroy()
#  win = undefined
#  return

export default  =>
  工具条()
  win.setIgnoreMouseEvents(true, { forward: true })
  倒计时()
  return
